package com.bitsfromspace.ubertorrent.tracker;

import java.io.IOException;

/**
 * An abstract Torrent Request.
 * @author: chris.oudeman
 * @since: Jan 6, 2011
 * @see TorrentHttpRequest
 * @see TorrentUdpRequest
 */
public interface TorrentRequest {

	public enum RequestEvent {
		STARTED, STOPPED, COMPLETED, NONE;

		@Override
		public String toString() {

			switch (this) {
			case COMPLETED:
				return "completed";
			default:
			case NONE:
				return "";
			case STARTED:
				return "started";
			case STOPPED:
				return "stopped";
			}
		}
	};

	/**
	 * Executes the torrent request and returns the {@link TorrentResponse}.
	 * @throws IOException on I/O error.
	 * @param timeoutInMillis Timeout in milliseconds before the request times out. When a request times out, an IOException will be thrown.
	 */
	TorrentResponse execute(int timeoutInMillis) throws IOException;
	
}


